Skip to content

Passing your own template as an attribute#15

Open
vrinceanuv wants to merge 5 commits intostofolus:masterfrom
vrinceanuv:master
Open

Passing your own template as an attribute#15
vrinceanuv wants to merge 5 commits intostofolus:masterfrom
vrinceanuv:master

Conversation

@vrinceanuv
Copy link

@vrinceanuv vrinceanuv commented Oct 21, 2016

The possibility to have your own template by passing the template path as a attribute or using the default one from distribute folder

You need a localhost server to have it working due to cross origin. (http-server should work)
https://www.npmjs.com/package/http-server

- Added a separate template for the slider
- Possibility of having your own template by passing the template path as a attribute
@stofolus
Copy link
Owner

Hello @vrinceanuv and thank you for you contribution.

I understand what your need it but I'm not sure if this would be the best way of solving it. This would require every project that wants to use the default template to make additional configuration in their buildchain (If I'm wrong please let me know).

I think there might be a few other solutions to this that would require less work from everyone using the plugin.

  • Use html2jsto package the template with the js code
  • Keep the template in a variable inside the directive and use that if attr.templateUrl isn't set
  • Use an optional transclude with a default template

@vrinceanuv
Copy link
Author

@stofolus You are right, indeed.

I am thinking at a solution of having a fallback to template when we don't have a templateUrl defined. So far, I haven't found a solution. Will update as soon as I have one and let you know. If you have something in mind that would be great.

@stofolus
Copy link
Owner

I can probably throw together a small PR tonight and you can have a look at it and let me know if that would work for your needs

@vrinceanuv
Copy link
Author

Thanks. What I need is to be able to pass my own template. This is what I tried to get done here, but for sure, it brakes functionality for others using this already.

@vrinceanuv
Copy link
Author

And why I try to do this? Because i want to use the npm package(https://www.npmjs.com/package/angular-range-slider) to do that and just use it in my project instead of changing the directive locally. So far no idea for the solution poped up.

@stofolus
Copy link
Owner

What kind of changes do you need locally? Maybe it can be solved some other way?

@vrinceanuv
Copy link
Author

vrinceanuv commented Oct 22, 2016

I tried to change the template from another directive, but without any chance. I need some additions to the template which are required depending on how many steps i have. I require a separator(mark-up and style) after every step. This is why I needed another template.

- Added a separate template for the slider
- Possibility of having your own template by passing the template path as a attribute
- Fallback to default template if template-url attribute not specified
@vrinceanuv
Copy link
Author

@stofolus I found a solution to this problem. If user specifies "template-url" attribute, the template specified will be used, if not the default inline defined template will be used. You can test this as well, I just did and it works as supposed. Also i removed the grunt-copy and the other non-sense.

@vrinceanuv
Copy link
Author

@stofolus Have you had some time to look over this? Thanks

@stofolus
Copy link
Owner

I haven't had a chance yet. I'll try to look at it tonight

@vrinceanuv vrinceanuv changed the title Features Passing your own template as an attribute Nov 5, 2016
@vrinceanuv
Copy link
Author

@stofolus I don't want to be a pain, but maybe these days you will have 10-15 minutes to take a look at the PR and test out the feature added. Thanks

@stofolus
Copy link
Owner

Sorry for the late response. I'm not sure if I like this solution. I feel like manually compiling the template is hacky. I'm also questioning how many people would have a need of a custom template when the template is so tightly coupled with the directive.

Would it instead be possible to add opt-in functionality that would add a line for every step?

@vrinceanuv
Copy link
Author

Hey, well I added something you suggested. So what this thing does is actually give the dev the opportunity to add its own template and it is the only way given the inline template definition. I couldn't find another way around given the directive built.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants